package com.game.server.message.proto.execute;

import com.comm.ISession;
import com.game.majiang.config.LogManager;
import com.game.majiang.logic.LogicClient;
import com.game.majiang.logic.LogicServer;
import com.game.majiang.logic.LogicTable;
import com.game.server.message.proto.in.AbstractleaveReq;
import com.game.server.message.proto.out.LeaveRsp;
import com.game.server.message.proto.out.OtherLeaveRoom;

public class leaveReq extends AbstractleaveReq {

    @Override
    public void Execute(ISession session) {

        LogManager.getInstance().Log("离开");
        LogicClient client = (LogicClient) LogicServer.getInstance().getClient(session.getId());
        if (client != null&&client.checkClick(msgcode)) {
        	LeaveRsp rsp = new LeaveRsp();
            if(client.getRoom() != null && client.getTable() != null)
            {         
            	LogicTable table = (LogicTable) client.getTable();
            	if(!table.leave(client)) {
        			rsp.setIsOK((byte) 1);
                  	client.Send(rsp);
        		}
            }
            else
            {
            	rsp.setIsOK((byte) 2);//没有房间
            	 client.Send(rsp);
            }
        }
    }
}
